<?php
namespace app\decorate\model;
use app\BaseModel;
use think\facade\Db;



class AdminStyle extends BaseModel
{
    //定义表名 风格表
    protected $name = 'longbing_card_decorate_style';

    /**
     * @param $query
     * 查询范围
     */
    public function scopeStatus($query, $status){
        $query->where('status', '>', $status);
    }
    /**
     * @param $dis
     * @return array
     * @throws \think\exception\DbException
     * 风格列表
     */
    public function styleList($dis,$page = 10){
        $data = $this->where($dis)->status(-1)->order('sort desc')->paginate($page)->toArray();
        return $data;
    }

    /**
     * User: chenniang
     * Date: 2019-10-12 09:54
     * @param $dis
     * @return mixed
     * descption:查询风格
     */
    public function styleSelect($dis){
        $data = $this->where($dis)->status(-1)->order('sort desc')->select()->toArray();
        return $data;
    }

    /**
     * @param $data
     * @return int|string
     * 添加风格
     */
    public function styleAdd($data){
        $data['create_time'] = time();
        $data['update_time'] = time();
        $res = $this->insert($data);
        return $res;
    }
    /**
     * @param $dis
     * @param $data
     * @return AdminCate
     * 编辑风格
     */
    public function styleUpdate($dis,$data){
        $data['update_time'] = time();
        $res = $this->where($dis)->update($data);
        return $res;

    }
    /**
     * @param $dis
     * @return AdminCate
     * 风格详情
     */
    public function styleInfo($dis){
        $data = $this->where($dis)->status(-1)->find();
        return !empty($data)?$data->toArray():$data;
    }
    /**
     * User: chenniang
     * Date: 2019-10-15 11:44
     * @param $dis
     * @return mixed
     * descption:区域名称
     */
    public function styleTitle($dis,$bat = 'title'){
        $data = $this->where($dis)->status(-1)->value($bat);
        return !empty($data)?$data:'暂无';
    }




}